# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=arduino-cli
pkgver=0.34.2
pkgrel=1
arch=('loong64' 'x86_64')
pkgdesc='Arduino command line interface'
url='https://github.com/arduino/arduino-cli'
license=('GPL3')
groups=('arduino')
depends=('glibc')
makedepends=('go' 'git')
source=("git+$url.git#tag=$pkgver")
sha512sums=('SKIP')

build(){
  cd $pkgname

  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export CGO_LDFLAGS="$LDFLAGS"
  export GOFLAGS='-buildmode=pie -trimpath -mod=readonly -modcacherw'

  go build \
        -ldflags "-linkmode=external -X github.com/arduino/arduino-cli/version.versionString=$pkgver-arch -X github.com/arduino/arduino-cli/version.commit=$(git rev-parse HEAD)" \
        -v .
}

package() {
  install -Dm 755 $pkgname/$pkgname "$pkgdir"/usr/bin/$pkgname
}
